      SUBROUTINE TAVISPAK3A2(NLOOP,ANGREQ,UTARG,EA,RAMFCN,ORBDATA,
     *                LUERR,IERR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE TAVISPAK SUBROUTINE SET. IT COMPUTES
C RAM FUNCTION VALUES USED BY THE TAVISPAK SUBROUTINE.
C
C VARIABLE DIM TYPE I/O DESCRIPTION
C -------- --- ---- --- -----------
C
C NLOOP     1   I*4  I  ITERATION NUMBER. NEEDED BECAUSE SOME PARAMETERS
C                       ARE CONSTANT THROUGHT THE ITERATION PROCESS AND
C                       ARE COMPUTED JUST ONCE.
C
C ANGREQ    1   R*8  I  SAME DESCRIPTION AS IN TAVISPAK.
C
C UTARG     1   R*8  I  SAME DESCRIPTION AS IN TAVISPAK.
C
C EA        3   R*8  I  ECCENTRIC ANOMALIES AT WHICH THE RAM FUNCTION
C                       VALUES ARE WANTED.
C
C RAMFCN    3   R*8  O  RAM FUNCTION VALUES.  EI(I) YIELDS RAMFCN(I)
C
C ORBDATA   *   R*8  I  VALUES OF QUANTITES NEEDED TO COMPUTE RAMFCN.
C                       SET IN TAVISPAK. SEE TAVISPAK FOR DIMENSION.
C
C***********************************************************************
C
C CODED BY C PETRUZZO, GSFC/742, 10/85  AND  H SWARTWOOD 12-85
C        MODIFIED....
C
C***********************************************************************
C
C
      REAL*8 VEL(3),P(3),Q(3),UTARG(3),EA(3),RAMFCN(3),
     *       ORBDATA(1),ANGOLD/1.D10/
      REAL*8 DEGRAD / 57.29577951308232D0 /
C
      IBUG = 0
      LUBUG = 19
C
      IF(IBUG.NE.0) WRITE(LUBUG,8001) NLOOP,ANGREQ*DEGRAD,UTARG,
     *               (EA(I)*DEGRAD,I=1,3),ORBDATA
 8001 FORMAT(/,' TAVISPAK3A DEBUG. ENTRY VALUES.  NLOOP=',I3,
     *             '  ANGREQ=',G13.5/,
     * '    UTARG=',3G13.5/,
     * '    EA=   ',3G13.5/,
     * '    ORBDATA=',(T15,3G16.8))
C
      IERR = 0
C
      IF(NLOOP.EQ.1) THEN
        SMA =   ORBDATA( 1)
        P(1) =  ORBDATA( 3)
        P(2) =  ORBDATA( 4)
        P(3) =  ORBDATA( 5)
        Q(1) =  ORBDATA( 6)
        Q(2) =  ORBDATA( 7)
        Q(3) =  ORBDATA( 8)
        TERM3 = ORBDATA( 9)
        TERM1 = ORBDATA(10)
        IF(ANGREQ.NE.ANGOLD) THEN
          COSREQ = DCOS(ANGREQ)
          ANGOLD = ANGREQ
          END IF
        END IF
C
C COMPUTE THE RAM FUNCTIONS RELATED TO THE ECCENTRIC ANOMALIES
C
      DO IPT=1,3
C
C      COMPUTE THE CARTESIAN VELOCITY VECTOR OF THE S/C IN ORBIT PLANE
C      COORDINATES.
        ECANOM = EA(IPT)
        TEMP = DCOS(ECANOM)
        TERM2 = 1.D0 - ECC * TEMP
        XDOT = -TERM3 * DSIN(ECANOM) / TERM2
        YDOT =  TERM3 * TERM1 * TEMP / TERM2
        VMAG = DSQRT(XDOT*XDOT + YDOT*YDOT)
C
C      COMPUTE THE CARTESIAN VELOCITY VECTOR IN THE SAME COORDINATE
C      SYSTEM AS TARGET LOCATION IS EXPRESSED.
        VEL(1) = (XDOT * P(1))  +  (YDOT * Q(1))
        VEL(2) = (XDOT * P(2))  +  (YDOT * Q(2))
        VEL(3) = (XDOT * P(3))  +  (YDOT * Q(3))
C
C      COMPUTE THE RAM FUNCTION
        RAMFCN(IPT) = -DOT(UTARG,VEL) / VMAG + COSREQ
C
        IF(IBUG.NE.0) WRITE(LUBUG,8002)
     *           IPT,ECANOM*DEGRAD,RAMFCN(IPT),VEL
 8002   FORMAT(' TAVISPAK3A2 DEBUG.  IPT=',I2,'  ECANOM=',G13.5,
     *             '   RAMFCN=',G13.5/,
     *         '   VEL=',3G16.8)
        END DO
C
 9999 CONTINUE
      RETURN
      END
